<html>
<head><meta charset="utf-8"><title>rc_buffer · clippy · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/index.html">clippy</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/rc_buffer.html">rc_buffer</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="213311158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/rc_buffer/near/213311158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/rc_buffer.html#213311158">(Oct 14 2020 at 15:54)</a>:</h4>
<p>Hi! I'm trying to fix a Clippy lint called <a href="https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer">https://rust-lang.github.io/rust-clippy/master/index.html#rc_buffer</a>.</p>
<p>In my case it had suggested to use <code>Rc&lt;[MyType]&gt;</code> rather than <code>Rc&lt;Vec&lt;MyType&gt;&gt;</code>.<br>
When trying to create a new instance of that type, I get compilation errors that [MyType] doesn't implement <code>Sized</code> required by <code>Rc</code>.<br>
I wonder how to construct a new instance of this suggested type that satisfies the lint?</p>
<p>I have constructed a tiny playground snippet to demonstrate.<br>
<a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=c2741a5eb8ea2d4c87562800f8c6ec13">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=c2741a5eb8ea2d4c87562800f8c6ec13</a></p>



<a name="213313095"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/rc_buffer/near/213313095" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/rc_buffer.html#213313095">(Oct 14 2020 at 16:07)</a>:</h4>
<p>The playground example doesn't trigger the lint for me. The "unsized" error doesn't come from the type declaration, but from the initialization. For <code>Rc&lt;str&gt;</code>, you can e.g. initialize it with <code>let _: Rc&lt;str&gt; = "".into();</code></p>



<a name="213313692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/rc_buffer/near/213313692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/rc_buffer.html#213313692">(Oct 14 2020 at 16:10)</a>:</h4>
<p>I believe the lint is recent and is triggered only on nightly.</p>



<a name="213313951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/rc_buffer/near/213313951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Alex Tokarev <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/rc_buffer.html#213313951">(Oct 14 2020 at 16:12)</a>:</h4>
<p><code>Vec::new().into()</code>seems to work as well, thank you for the suggestion <span class="user-mention" data-user-id="264664">@Philipp Krones</span>. I'll see if I can do that throughout my project.</p>



<a name="213314101"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257328-clippy/topic/rc_buffer/near/213314101" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> flip1995 <a href="https://rust-lang.github.io/zulip_archive/stream/257328-clippy/topic/rc_buffer.html#213314101">(Oct 14 2020 at 16:13)</a>:</h4>
<p>Yes, it was also recently downgraded to an allow-by-default <code>restriction</code> lint (which means, that you'll have to enable it by hand, if you really want it). But this change still has to hit nightly, which will take about another week or so. </p>
<p>You should therefore feel free to ignore this lint <del>for now</del> if you don't like it.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>